package com.example.orderconsumer.controller;

import com.example.orderconsumer.bean.OrderRequest;
import com.example.orderconsumer.biz.OrderBizService;
import com.example.orderconsumer.service.OrderService;
import com.example.orderconsumer.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order-consumer")
public class OrderConsumerController {
    @Autowired
    private OrderBizService orderBizService;

    @Autowired
    private ProductService productService;

    @Autowired
    private OrderService orderService;

    @PostMapping("/place")
    public String placeOrder(@RequestBody OrderRequest request) {
        return orderBizService.placeOrder(request);
    }

    @RequestMapping("/findProduct/{productId}")
    public Object findProduct(@PathVariable Long productId) {
        return productService.findById(productId);
    }

    @RequestMapping("/findAllOrder")
    public Object findAllOrder() {
        return orderService.findAll();
    }
}